<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<script type="text/javascript">
function deleteCheck(no,currentPage){
	if(confirm(no + " 번 글을 삭제하시겠습니까?")){
		alert('삭제되었습니다.');
		location.href="deleteAction.action?no="+ no +"&currentPage="+ currentPage;
	}; 
}

function modifyCheck(no,currentPage){
	if(confirm(no + " 번 글을 수정하시겠습니까?")){
		location.href="modifyForm.action?no="+ no +"&currentPage="+ currentPage;
	}; 
}

function commentCheck() {
	var frm = document.forms(0);
	if (frm.content.value == "") {
		alert("내용을 입력해주세요.");
		return false;
	}
	return true;
}

function deleteCheck2(no,currentPage,originno){
	if(confirm("작성하신 코멘트를 삭제하시겠습니까?")){
		alert('삭제되었습니다.');
		location.href="deleteAction2.action?no="+ no +"&currentPage="+ currentPage+"&originno="+originno;
	}; 
}

</script>

<script type="text/javascript">
	function open_win_noresizable(url, name)
	{
		var oWin = window.open(url, name, "scrollbars=no, status=no, resizable=no, width=300, height=150");
	}
</script>
<h2 class="page_title"><strong>자유 게시판</strong></h2>
<table class="table_view">
	<colgroup>
		<col width="120px" />
		<col />
	</colgroup>
	<tr>
		<th>번호</th>
		<td>
			<s:property value="resultClass.no" />
		</td>
	</tr>
	<tr>
		<th>말머리</th>
		<td>
			<s:property value="resultClass.whole" />
		</td>
	</tr>
	<tr>
		<th>제목</th>
		<td>
			<s:property value="resultClass.subject" />
		</td>
	</tr>
	<tr>
		<th>닉네임</th>
		<td>
		<s:property value="resultClass.nickname" />
		</td>
	</tr>
	<tr>
		<th class="table_content">내용</th>
		<td class="table_content">
			<s:property value="resultClass.content" />
		</td>
	</tr>
	<tr>
		<th>조회수</th>
		<td>
			<s:property value="resultClass.readhit" />
		</td>
	</tr>
	<tr>
		<th>등록날짜</th>
		<td>
			<s:property value="resultClass.regdate" />
		</td>
	</tr>
	<tr>
		<th>첨부파일</th>
		<td>
			&nbsp;&nbsp;
			<s:url id="download" action="fileDownloadAction">
				<s:param name="no">
					<s:property value="no" />
				</s:param>
			</s:url>
			
			<s:a href="%{download}">
				<s:property value="resultClass.file_orgname" />
			</s:a>
		</td>
	</tr>
</table>

<p class="align_r">
<s:url id="modifyURL" action="modifyAction">
	<s:param name="no">
		<s:property value="no" />
	</s:param>
</s:url>
<s:url id="deleteURL" action="deleteAction">
	<s:param name="no">
		<s:property value="no" />
	</s:param>
</s:url>
<p class="align_r">
	<input name="list" type="button" value="답변달기" class="inputb" onClick="javascript:location.href='replyForm.action?no=<s:property value="no" />'">
	<s:if test="#session.session_id == resultClass.id">
	<input type="button" value="수정" class="inputb" onClick="javascript:modifyCheck('<s:property value="no"/>','<s:property value="currentPage" />');">
	<input type="button" value="삭제" class="inputb" onClick="javascript:deleteCheck('<s:property value="no"/>','<s:property value="currentPage" />');">
	</s:if>
	
		
	<input name="list" type="button" value="목록" class="inputb" onClick="javascript:location.href='listAction.action?currentPage=<s:property value="currentPage" />'">
</p>

<h3><strong>COMMENT</strong></h3>
<table class="table_list">
	<colgroup>
		<col width="180px" />
		<col />
		<col />
		<col />
	</colgroup>
	<tr>
		<th>ID</th>
		<th>NICKNAME</th>
		<th>COMMENT</th>
		<th>DEL</th>
		<th>DATE</th>
	</tr>
	<s:iterator value="commentlist" status="stat">
	<tr>
		<td><s:property value="id" /></td>
		<td><s:property value="nickname" /></td>
		<td><s:property value="content" /></td>
		
		
   		<td>
   		<s:if test="#session.session_id == id">
			<a href="javascript:deleteCheck2('<s:property value="no"/>','<s:property value="currentPage" />','<s:property value="originno" />');"><font color="red"><strong>DEL</strong></font></a>
		</s:if>
		</td>
		
		
		<td><s:property value="regdate" /></td>
	</tr>
	</s:iterator>
	<s:if test="commentlist.size() <= 0">
	<tr>
		<td colspan="5">
			작성된 코멘트가 없습니다. 
		</td>
	</tr>
	</s:if>	
</table>
<form action="writeCommentAction.action" method="post"enctype="multipart/form-data"onsubmit="return commentCheck();">
<fieldset>
<legend>덧글쓰기</legend>
	<s:hidden name="originno" value="%{resultClass.no}" />
	<s:hidden name="no" value="%{resultClass.no}" />
	<s:hidden name="currentPage" value="%{currentPage}" />
	<table>
		<tr>
			<td><%-- <s:if test="#session.session_id==null">셋</s:if><s:else>${session.session_id}</s:else>
				<s:textfield name="name" theme="simple" value="${session.session_id}" maxlength="20" readonly="readonly"/> --%>
				<input type="text" name="id" value="${session.session_id}" maxlength="20" readonly="readonly" class="align_c"/>
				<input type="text" name="nickname" value="${session.session_nickname}" maxlength="20" readonly="readonly" class="align_c"/>
			</td>
			<td>
				<s:textarea name="content" theme="simple" value="" cols="60" rows="3" />
			</td>
			<td><input name="submit" type="submit" value="WRITE" /></td>
		</tr>
	</table>
</fieldset>
</form>

